﻿# Class that creates PONO class from Json object

class SPCoderJsonItem:
    "The class responsible for handling one json item"
    def __init__(self, item):
        self._ObjectItem = item
    
    def __setattr__(self,  name, value):
        self.__dict__[name] = value
    
class SPCoderJson:
    "The class responsible for handling Json object as list"
    def __init__(self, my_list):
       
        #my_data = my_list["data"]
        my_data = my_list
        my_keys = []
        if (my_data.Count > 0):
            for kk in my_data[0].Keys:
                my_keys.Add(kk)
        
        self.Items = []
        for my_item in my_data:
            my_it = SPCoderJsonItem(my_item)
            for my_field in my_keys:
                my_it.__setattr__(my_field, my_item[my_field])
            self.Items.Add(my_it)